home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tcsel003.zip / EXPFHT.PAS < prev    next >
Pascal/Delphi Source File  |  1992-10-16  |  2KB  |  75 lines

  1. unit expfht;
  2.  
  3.   { Author: Trevor J Carlsen  Released into the public domain }
  4.   {         PO Box 568                                        }
  5.   {         Port Hedland                                      }
  6.   {         Western Australia 6721                            }
  7.   {         Voice +61 91 732 026                              }
  8.  
  9.   { EXPFHT: This unit allows an application to expand the number of file }
  10.   { handles in use. It is limited to the number permitted by DOS and     }
  11.   { initialised in the FILES= of the config.sys file.                    }
  12.  
  13. interface
  14.  
  15. const
  16.   NumbFiles= 105;
  17.   { Set to the number of file handles needed. 99 will be the max with }
  18.   { DOS 2.x and 254 with DOS 3.x. (I don't know why not 255!)         }
  19. type
  20.   fht      = array[1..NumbFiles] of byte;
  21. var
  22.   NewFHT   : fht;
  23.   OldFHT   : longint;
  24.   OldSize  : word;
  25.                     
  26. function MakeNewFHT: boolean;
  27. procedure RestoreOldFHT;
  28.  
  29.  
  30. implementation
  31.  
  32. const
  33.   Successful : boolean = false;
  34.  
  35. var
  36.   OldExitProc  : pointer;
  37.  
  38. {$R-}
  39. function MakeNewFHT : boolean;
  40.   { create a new expanded file handle table - TRUE if successful }
  41.   const
  42.     AlreadyUsed : boolean = false;
  43.   begin
  44.     if not AlreadyUsed then begin
  45.       AlreadyUsed := true;
  46.       MakeNewFHT := true;
  47.       Successful := true;
  48.       OldFHT  := MemL[PrefixSeg:$34];            { Store the old FHT address }
  49.       FillChar(NewFHT,NumbFiles,$ff);              { Fill new table with 255 }
  50.       Oldsize := MemW[PrefixSeg:$32];               { Store the old FHT size }
  51.       MemW[PrefixSeg:$32] := NumbFiles;            { Put new size in the psp }
  52.       MemL[PrefixSeg:$34] := longint(@NewFHT);      { new FHT address in psp }
  53.       move(Mem[PrefixSeg:$19],NewFHT,$15);      { put contents of old to new }
  54.     end { if not AllreadyUsed }
  55.     else MakeNewFHT := false;
  56.   end; { MakeNewFHT }
  57. {$R+}
  58.  
  59. {$F+}
  60. procedure RestoreOldFHT;
  61.   begin
  62.     ExitProc := OldExitProc;
  63.     if Successful then begin
  64.       MemW[PrefixSeg:$32] := OldSize;
  65.       MemL[PrefixSeg:$34] := OldFHT;
  66.     end;  
  67.   end;
  68. {$F-}
  69.  
  70. begin
  71.   OldExitProc := ExitProc;
  72.   ExitProc    := @RestoreOldFHT;
  73. end.
  74.  
  75.